;; 编码设置
(set-language-info
 "Chinese-UTF8"
 'coding-priority
 '(utf-8 gbk gb18030 gb2312 iso-2022-cn chinese-big5 chinese-iso-8bit iso-8859-1))
(set-language-environment "Chinese-UTF8")
(setq default-buffer-file-conding-system 'utf-8) ;; 默认新建文件使用的编码
(prefer-coding-system 'utf-8)                    ;; 指定默认编码

;; 设置个人信息
(setq user-full-name "Foob Hao")
(setq user-mail-address "xfoob@qq.com")

;; 自定义变量，用于判断系统
(defvar my/is-win (memq system-type '(ms-dos cygwin windows-nt)))
(defvar my/is-linux (eq system-type 'gnu/linux))
(defvar my/is-mac (eq system-type 'darwin))

;; 设置默认工作目录
(when my/is-win
  (setq default-directory "d:/tmp/")
  )

;; 配置文件目录
(add-to-list 'load-path "~/.emacs.d/lisp")
;; 这里存放单文件的插件与自定义功能
(add-to-list 'load-path "~/.emacs.d/site-lisp")

;; 设置缓存文件/杂七杂八的文件存放的地址
(setq user-emacs-directory "~/.emacs.d/var"
      desktop-dirname "~/.emacs.d/var/desktop"
      auto-save-list-file-prefix                    ; 设置自动保存路径前缀
      "~/.emacs.d/var/auto-save-list/.saves-"
      eshell-history-file-name                      ; 设置eshell历史记录
      "~/.emacs.d/var/eshell/history"
      custom-file                                   ; 设置custom.el文件的配置位置
      (expand-file-name "./custom.el" user-emacs-directory))
;; (load custom-file)

;; 文件模式挂载的例子，怕忘了，在这做个记录，是不是应该单位开一个文件记录？
;; (add-to-list 'auto-mode-alist '("\\.html" . web-mode))

(require 'init-base)
(require 'init-ui)
(require 'init-keybind)
(require 'init-hippie-expand)         ; hippie 默认开启
(require 'init-package)
(require 'init-whitespace)
(require 'my/auto-save)               ;自定义插件：自动保存

(add-hook 'after-init-hook
          (lambda ()
            ;; plugin configure
            (require 'init-edit)
            (require 'init-interactive)
            (require 'init-grep)
            (require 'init-consult)

            (require 'init-markdown)
            ;; (require 'init-latex)
            (require 'init-org)
            (require 'init-csv)

            (unless my/is-win
              (require 'init-pyim))

            ;; prog
            (require 'init-prog)
            (require 'init-eglot)
            (require 'init-corfu)
            (require 'init-treesit)
            (require 'init-project)
            ;; (require 'init-yasnippet)

            (require 'init-c)
            (require 'init-js)
            (require 'init-web)
            (require 'init-scheme)
            ;; (require 'init-python)
            ;; (require 'init-csharp)
            (require 'init-zig)
            ;; (require 'init-lua)
             ))


;; server
(require 'server)

(setq server-auth-dir (concat user-emacs-directory "/server/"))
(unless (server-running-p)
    (server-start))

(provide 'init)
